package com.example.boot.modules.auth.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.boot.modules.system.entity.User;
import com.example.boot.modules.system.service.IUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

/**
 * @author 王令
 * @since 2022/12/1 20:56
 */
@Service
@RequiredArgsConstructor
public class ExampleMobileUserDetailService implements MobileUserDetailsService, ExampleUserInfoService {

    private final IUserService service;

    @Override
    public UserDetails loadUserByMobile(String phone) {
        User user = service.getOne(Wrappers.<User>lambdaQuery().eq(User::getPhone, phone));
        return getUserDetailsInfo(service.findUserInfoByUser(user));
    }
}
